# region jinja2填充模板
from jinja2 import Template
import os


def template_replace(template_file_path, context_dc):
    assert os.path.exists(template_file_path)
    with open(template_file_path, encoding='utf-8') as fp:
        template = Template(fp.read())
    content = template.render(**context_dc)
    return content
# endregion


if __name__ == '__main__':
    template_file_path = 'templates/style_1.html'

    prefix_of_title = """
    Extended spectral-domain model for resonance suppression in permanent magnet synchronous motor vector control system 
    JIN Jiayue1，HUA Hua1,2，SHU Chang1，CHEN Jiaxin1
    （1.College of Mechanical Engineering, Donghua University, Shanghai, China; Xuancheng Meteorological Bureau, Xuancheng, Anhui, China）
    Abstract: Addressing at the problem that the spectral-domain model of the original vector control system has a significant error when directly employed for the performance analysis of high-speed and on-load system, the construction theory and process are reanalyzed. By identifying the root cause of the error, an extended spectral-domain model is proposed that can be directly used for the performance analysis of the permanent magnet synchronous motor vector control system. This is achieved by incorporating the role of back electromotive force and load into the system’s mathematical model and weakening the influence of the direct axis current on the system error. In addition, the application technology of the extended spectral-domain model in the system resonance suppression is also studied. The bandwidth before and after the system resonance suppression based on the analytical method and the calculation results of the resonance point and the anti-resonance point are given. Based on passing verification, the advanced correction network technology is further used to restore and expand the suppressed bandwidth. The research shows that the extended model not only has small error in performance analysis, but also can directly obtain the frequency response characteristics of the system by analytical method, which overcomes the limitations that the spectral-domain model of the original vector control system needs to use the frequency sweep experiment method to obtain the frequency response characteristics of the system under high speed and load. [footnoteRef:0]  [0: 收稿日期：2023-01-19
    通信作者：陈家新，男，教授，研究方向为电力电子、电机设计及其智能测控技术，E-mail: chjiaxin@dhu.edu.cn
    引用格式：金佳跃，华华，舒畅，等.永磁同步电机矢量控制系统扩展频域模型及其在谐振抑制中的应用[J].东华大学学报（自然科学版）, xxx.
    JIN J Y,HUA H, SHU C, et al. Extended spectral-domain model for resonance suppression in permanent magnet synchronous motor vector control system[J]. Journal of Donghua University(Natural Science), xxx.] 
    """

    context_dc = {
        'prefix_of_title': prefix_of_title,
        'cn_info': {
            'title': '这是标题',
            'authors': '张三, 李四, 王五.',
            'institutions': '1.北京大学\n2.清华大学.',
            'summary': '这是摘要...',
        },
        'en_info': {
            'title': 'Title_1',
            'authors': 'Zhang San, Li Si.',
            'institutions': '1. Beijing University;\n2. Qing Hua University.',
            'summary': 'summary...',
        },
        'content': '正文内容...',
    }
    template_replace(template_file_path, context_dc)